{% extends '_base.html' %}
{% block sidebar %}
<ul>
  <li><a href="/">Home</a></li>
  <li><a href="/?doorplate={{doorplate}}">Back</a></li>
</ul>
{% endblock %}
{% block script %}
<script language="javascript"> 
    function toggle(showHideDiv, switchTextDiv, hiddenValue) {
        var ele = document.getElementById(showHideDiv);
        var text = document.getElementById(switchTextDiv);
        var hid = document.getElementById(hiddenValue)
        if(ele.style.display == "block") {
            ele.style.display = "none";
            text.innerHTML = "Restore";
            hid.value="Deleted";
        }
        else {
            ele.style.display = "block";
            text.innerHTML = "Delete";
            hid.value="Normal";
        }
    } 
</script>
{% endblock %}
{% block content %}
<form method="post" action="/cell">
    <input type="hidden" name="doorplate" value="{{doorplate}}">
    <input type="hidden" name="label" value="{{b.getLabel()}}">
    <p>label: {{b.getLabel()}} </p>
    <p>url: <input type="text" name="url" value="{{b.getUrl()}}"></p>
    <p>mailto:<input type="text" name="mailto"value="{{b.getContact().1}}"></p>
    <p>mailtopic: <input type="text" name="topic" value="{{b.getContact().2}}"></p>
    {% for k in b.stuffs.items() %}
    <hr class="separator">
    <input type="hidden" id='hidden_{{k.0}}' name='hidden_{{k.0}}' value='Normal'>
    <table>
      <td><b>{{k.0}}</b></td>
      <td><a id='stats_stuff_{{k.0}}' class="delbutton" href="javascript:toggle('div_stuff_{{k.0}}','stats_stuff_{{k.0}}', 'hidden_{{k.0}}');">Delete</a></td>
    </table>
    <div id="stuff">
      <div id='div_stuff_{{k.0}}' style='display: block;'>
        <table>
          <tr>
            <td><p>pattern: <input type="text" name="pattern_{{k.0}}" value='{{k.1.getPattern()}}' ></p> </td>
            <td><p>message: <input type="text" name="message_{{k.0}}" value='{{k.1.getMessage()}}' ></p> </td>
          </tr>
          <tr>
            <td><p>lambda: <input type="text" name="lambda_{{k.0}}" value='{{k.1.getExpression().0}}' ></p></td>
            <td><p>param1: <input type="text" name="p1_{{k.0}}" value='{{k.1.getExpression().1}}' ></p></td>
            <td><p>param2: <input type="text" name="p2_{{k.0}}" value='{{k.1.getExpression().2}}' ></p></td>
          </tr>
        </table>
      </div>
    </div>
    {% endfor %}
    <hr class="separator">
    <div id="newstuff">
      <table>
        <tr>
          <td><p>item: <input type="text" name="item"></p> </td>
          <td><p>pattern: <input type="text" name="pattern" value='{{n.getPattern()}}' ></p> </td>
          <td><p>message: <input type="text" name="message" value='{{n.getMessage()}}' ></p> </td>
        </tr>
        <tr>
          <td><p>lambda: <input type="text" name="lambda" value='{{n.getExpression().0}}' ></p></td>
          <td><p>param1: <input type="text" name="p1" value='{{n.getExpression().1}}' ></p></td>
          <td><p>param2: <input type="text" name="p2" value='{{n.getExpression().2}}' ></p></td>
        </tr>
      </table>
    </div>
    <p><input type="submit" name="b1" value="Update" ></p>
</form>
{% endblock %}
{% block errmessage %}
<p>{{e}}</p>
{% endblock %}
{% block message %}
<p>{{m}}</p>
{% endblock %}
